<%--
  Created by IntelliJ IDEA.
  User: 陈金平
  Date: 2020/11/20
  Time: 16:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script type="text/javascript">
        function delDepartments() {
            $("#department-form").submit();
        }
    </script>
    <title>科室列表</title>
</head>

<body>
<h1 class="text-center pt-3 pb-3">科室列表</h1>

<div class="container">
    <div class="offset-md-4 col-md-4">
        <div class="pl-2">
            <form class="form-inline">
                <div class="form-group">
                    <button type="button" onclick="window.open('/goto_add_department')" class="btn btn-sm btn-outline-secondary">新增医生</button>
                    &nbsp;&nbsp;
                    <button type="button" onclick="delDepartments()" class="btn btn-sm btn-outline-secondary">批量删除</button>
                </div>
            </form>
        </div>

        <hr>

        <form id="department-form" action="/del_departments" method="post">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>选择</th>
                    <th>编号</th>
                    <th>科室</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${departments}" var="d">
                    <tr>
                        <td class="text-center">
                            <input type="checkbox" class="form-check-input" name="did" value="${d.did}">
                        </td>
                        <td>${d.did}</td>
                        <td>${d.dname}</td>
                        <td>
                            <a href="/goto_set_department?did=${d.did}">修改</a> /
                            <a href="/del_department?did=${d.did}">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </form>
    </div>
</div>
</body>
</html>
